﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace CommonLibraries.DeviceLibrary.Controls
{
    public partial class GpsSummary : UserControl
    {
        GPS m_GPS = null;

        public GpsSummary()
        {
            InitializeComponent();
            //m_GPS = new GPS();
            m_GPS.PowerState = PowerStates.On;
            //m_GPS.HasSolutionChanged += new EventHandler(m_GPS_HasSolutionChanged);
            timer1.Enabled = true;
            timer1.Interval = 100;
        }

        private void m_GPS_HasSolutionChanged(object sender, EventArgs e)
        {
            //this.transparentLabelAltitude.Text = "a";
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (m_GPS.HasSolution)
            {
                this.transparentLabelAltitude.Text = m_GPS.NmeaGGA.Altitude.ToString();
                this.transparentLabelHasSolution.Text = m_GPS.HasSolution.ToString();
                this.transparentLabelLongitude.Text = m_GPS.NmeaGGA.Longitude.ToString();
                this.transparentLabelLatitude.Text = m_GPS.NmeaGGA.Latitude.ToString();
                this.transparentLabelQuality.Text = m_GPS.NmeaGGA.Quality.ToString();
                this.transparentLabelSateliteCount.Text = m_GPS.NmeaGGA.SateliteCount.ToString();
                this.transparentLabelTimestamp.Text = m_GPS.NmeaGGA.SateliteTime.ToString();
            }
            this.transparentLabelTime.Text = DateTime.Now.ToString();
        }

        private void buttonPowerOn_Click(object sender, EventArgs e)
        {
            m_GPS.PowerState = PowerStates.On;
            this.transparentLabelPower.Text = m_GPS.PowerState.ToString();
        }

        private void buttonReset_Click(object sender, EventArgs e)
        {
            m_GPS.Reset();
        }

        private void buttonExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

    }
}
